<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.atguigu.pojo.Student" %>
<%@ page import="java.util.List" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2023/4/11
  Time: 16:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%--1,遍历1到10,输出
     begin 属性设置开始索引
     end 属性设置结束索引
     var 属性表示循环的变量
--%>
<table border="1">
    <c:forEach begin="1" end="10" var="i">
        <tr>
            <td> 第${ i}行<br></td>
        </tr>
    </c:forEach>
</table>

<hr>
<%-- 2.遍历Object数组 --%>
<%
    request.setAttribute("arr", new String[]{"18610541354", "5248455858", "141154154"});
%>
<c:forEach items="${requestScope.arr}" var="item">
    ${item}
</c:forEach>
<table border="1">
    <c:forEach items="${requestScope.arr}" var="item">
        <tr>
            <td> ${item} <br></td>
        </tr>
    </c:forEach>
</table>

<hr>
<%
    Map<String, Object> map = new HashMap<>();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");
    map.put("key4", "value4");
    request.setAttribute("map", map);
%>
<c:forEach items="${requestScope.map}" var="entry">
<h1>${entry.key}----${entry.value}
    <h1>
        </c:forEach>


            <%
           List<Student> studentList = new ArrayList<>();
           for(int i = 1; i <=10 ; i++) {
             studentList.add(new Student(1,"username"+1,18+i,"asdf"+i));
           }
           request.setAttribute("stus",studentList);
        %>
        <table>
            <tr>
                <th>
                    变暗好
                </th>
            </tr>
        </table>
        <c:forEach items="${requestScope.stus}" var="stu">
            ${stu} <br>
        </c:forEach>
</body>
</html>
